#include "proc/process.h"

// bool proc_pid_cmdline_of_path(int pid, ProcProcess *info) {}
// bool proc_pid_comm_of_path(int pid, ProcProcess *info) {}

// bool proc_pid_comm_of_buffer(int pid, ProcProcess *info) {
//     if (isNull(buf)) return false;
//     return true;
// }

bool get_comm_by_pid(char *pid, char *comm, size_t len) {
    char path[PROCESS_C_MAX] = {0};
    sprintf(path, "%s/%s/%s",PROC_PID_DIR, pid, PROC_PID_COMM);
    return FileReadToBuffer(path, comm, len);
}

bool initProcessByPid(int pid, ProcProcess *info) {
    char buffer[10000] = {0};
    char path[PROCESS_C_MAX] = {0};

    S_CLEARN(path);
    S_CLEARN(buffer);
    sprintf(path, "%s/%d/%s",PROC_PID_DIR, pid, PROC_PID_COMM);
    FileReadToBuffer(path, info->comm, PROCESS_C_MAX);

    S_CLEARN(path);
    S_CLEARN(buffer);
    sprintf(path, "%s/%d/%s",PROC_PID_DIR, pid, PROC_PID_COMM);

    return true;
}